package cn.school.service;

import cn.school.dao.SubjectDao;
import cn.school.entity.Page;
import cn.school.entity.Subject;
import cn.school.util.LogUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
@Service
public class SubjectService {
    @Autowired
    private  SubjectDao dao;

    public List<Subject> findALL() {

            return dao.findALL();

    }

    public int add(Subject sub) {

            return dao.add(sub);

    }

    public Page<Subject> search(int pageNo,int pageSize){

            List<Subject> list = dao.search(pageNo, pageSize);
            int i = dao.searchTotal();
            return new Page<Subject>(pageNo,pageSize,i,list);

    }

    public boolean del(long id) {

            int r = dao.del(id);
            return r > 0;

    }

    public Subject get(long id) {

            return dao.get(id);

    }

    public int update(Subject sub) {

            return dao.update(sub);

    }

    public boolean checkSubName(String name) {

            return dao.checkSubName(name)>=1;

    }
}
